/**
 * 上海中赢金融信息服务有限公司
 * Copyright (c) 2017-2027 Chinazyjr,Inc.All Rights Reserved.
 */

package com.sys.midware.assist.utils.thread;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * <b>ClassName:</b> TestTask.java <br/>
 * <b>Description:</b> TODO <br/>
 * <b>Date:</b> 2016年4月22日 下午3:14:00<br/>
 * 
 * @author mobing
 * @version
 */
public class ThreadOperate {

    private static final Logger logger = LoggerFactory.getLogger(ThreadOperate.class);

    // 暂停标记
    private volatile boolean pause = false;

    // 停止标记
    private volatile boolean stop = false;

    // 启动标记
    private volatile boolean start = false;

    public boolean isPause() {
        return pause;
    }

    public boolean isStop() {
        return stop;
    }

    public boolean isStart() {
        return start;
    }
    /**
     * 操作线程等待
     * @param  
     * @return  void
     */
    public void bwait() {
        synchronized (this) {
            try {
                this.wait();
            } catch (InterruptedException e) {
                logger.error("bwait error!", e);
            }
        }
    }
    /**
     * 操作线程中断
     * @param  
     * @return  void
     */
    public void binterrupte() {
        synchronized (this) {
            try {

                Thread.currentThread().interrupt();
            } catch (Exception e) {
                logger.error("binterrupte error!", e);
            }
        }
    }

    public synchronized void pauseThread() {
        this.pause = true;
    }

    public synchronized void resumeThread() {
        this.pause = false;
        this.notifyAll();
    }

    public synchronized void stopThread() {
        this.stop = true;
    }

    public synchronized void startThread() {
        this.stop = false;
    }

}
